/*
 Navicat Premium Dump SQL

 Source Server         : AAA-localhost-mysql
 Source Server Type    : MySQL
 Source Server Version : 80040 (8.0.40)
 Source Host           : localhost:3306
 Source Schema         : wmall_product

 Target Server Type    : MySQL
 Target Server Version : 80040 (8.0.40)
 File Encoding         : 65001

 Date: 26/04/2025 00:20:54
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for cart
-- ----------------------------
DROP TABLE IF EXISTS `cart`;
CREATE TABLE `cart` (
  `cart_id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned NOT NULL DEFAULT '0' COMMENT '用户 Id',
  `product_id` bigint unsigned NOT NULL DEFAULT '0' COMMENT '商品 Id',
  `product_num` int unsigned NOT NULL DEFAULT '0' COMMENT '商品数量',
  `valid` bit(1) NOT NULL DEFAULT b'1' COMMENT '是否有效：1 有效，0 无效',
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`cart_id`) USING BTREE,
  KEY `idx_user_id` (`user_id`) USING BTREE,
  KEY `idx_product_id` (`product_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Records of cart
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for product
-- ----------------------------
DROP TABLE IF EXISTS `product`;
CREATE TABLE `product` (
  `product_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '商品 Id',
  `product_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '商品名称',
  `product_img` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '商品图片',
  `price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '价格',
  `stock` int unsigned NOT NULL DEFAULT '0' COMMENT '库存',
  `content` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '描述',
  `update_version` int unsigned NOT NULL DEFAULT '0' COMMENT '更新版本号，每次更新+1',
  `valid` bit(1) NOT NULL DEFAULT b'1' COMMENT '是否有效：1 有效，0 无效',
  `create_time` datetime NOT NULL,
  `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`product_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- ----------------------------
-- Records of product
-- ----------------------------
BEGIN;
INSERT INTO `product` (`product_id`, `product_name`, `product_img`, `price`, `stock`, `content`, `update_version`, `valid`, `create_time`, `update_time`) VALUES (1, '小米电视 60 寸', '/product/1.jpg', 1999.00, 1708, '小米电视说明', 292, b'1', '2025-03-20 23:54:15', '2025-04-26 00:19:12');
INSERT INTO `product` (`product_id`, `product_name`, `product_img`, `price`, `stock`, `content`, `update_version`, `valid`, `create_time`, `update_time`) VALUES (2, 'iPhone 14 Pro Max', '/product/2.jpg', 6899.00, 1708, '苹果手机说明', 292, b'1', '2025-04-06 22:54:02', '2025-04-26 00:19:12');
INSERT INTO `product` (`product_id`, `product_name`, `product_img`, `price`, `stock`, `content`, `update_version`, `valid`, `create_time`, `update_time`) VALUES (3, '联想 ThinkBook 办公笔记本', '/product/3.jpg', 4288.00, 1708, '笔记本电脑说明', 292, b'1', '2025-04-06 22:55:46', '2025-04-26 00:19:12');
COMMIT;

-- ----------------------------
-- Table structure for undo_log
-- ----------------------------
DROP TABLE IF EXISTS `undo_log`;
CREATE TABLE `undo_log` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `branch_id` bigint NOT NULL,
  `xid` varchar(100) NOT NULL,
  `context` varchar(128) NOT NULL,
  `rollback_info` longblob NOT NULL,
  `log_status` int NOT NULL,
  `log_created` datetime NOT NULL,
  `log_modified` datetime NOT NULL,
  `ext` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of undo_log
-- ----------------------------
BEGIN;
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
